//
//  BuyVcDetails.m
//  Wy_BuyBooks
//
//  Created by wangyang on 2020/2/6.
//  Copyright © 2020 wangyang. All rights reserved.
//

#import "BuyVcDetails.h"

@interface BuyVcDetails ()
@property (nonatomic,strong) UIScrollView  *WyScrollView;

@end

@implementation BuyVcDetails

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.navigationItem.title = @"订单详情";
    self.view.backgroundColor = UIColorFromRGB(0xF8F8F8);
    [self WyScrollView];
    if (@available(iOS 11.0, *)) {
        
        self.WyScrollView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
    }
    [self initSetUI];
}

-(void)initSetUI{
    
    
    for (int i = 0; i<3; i++) {
        UIView *lineView = [[UIView alloc]init];
        [self.WyScrollView addSubview:lineView];
        WyViewRadius(lineView, BiLiWidth(16)/2);
        lineView.tag = i;
        lineView.backgroundColor = UIColorFromRGB(0xCCCCCC);
        [lineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(16), BiLiWidth(16)));
            make.top.equalTo(self.LineView.bottom).offset(BiLiWidth(-8));
            make.left.mas_offset(BiLiWidth(90)+BiLiWidth(75+16)*i);
        }];
        if (lineView.tag == 0) {
            lineView.backgroundColor = UIColorFromRGB(0xFADB14);
        }
       
    }
    
    NSArray *oneArray = @[_BuyVcDetailsDicy[@"people"],_BuyVcDetailsDicy[@"phpne"],_BuyVcDetailsDicy[@"add"],_BuyVcDetailsDicy[@"time"]];
    for (int i = 0; i<oneArray.count; i++) {
        UILabel *labe = [UILabel labelWithContent:oneArray[i] superView:self.OneView textColor:UIColorFromRGB(0x666666) font:WySYSTEMFONT(14) textAlignment:NSTextAlignmentLeft];
        [labe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(300), BiLiWidth(20)));
            make.top.mas_offset(BiLiWidth(16)+BiLiWidth(24)*i);
            make.left.mas_offset(BiLiWidth(15));
        }];
    }
    
    
    NSArray *twoArray = @[@"支付方式：货到付款",@"订单编号：2676178128",@"创建时间：2020-01-01 12:00"];
    for (int i = 0; i<twoArray.count; i++) {
        UILabel *labe = [UILabel labelWithContent:twoArray[i] superView:self.TwoView textColor:UIColorFromRGB(0x666666) font:WySYSTEMFONT(14) textAlignment:NSTextAlignmentLeft];
        [labe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(300), BiLiWidth(20)));
            make.top.mas_offset(BiLiWidth(16)+BiLiWidth(24)*i);
            make.left.mas_offset(BiLiWidth(15));
        }];
        labe.tag = i;
        if (labe.tag == 0) {
            labe.textColor = UIColorFromRGB(0xFADB14);
        }
       }
    
    
    
   
    for (int i = 0; i<2; i++) {
           UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
           [self.view addSubview:btn];
           [btn addTarget:self action:@selector(selector:) forControlEvents:UIControlEventTouchUpInside];
           [btn mas_makeConstraints:^(MASConstraintMaker *make) {
               make.size.equalTo(CGSizeMake((WySCREENWIDTH)/2, BiLiWidth(49)));
               make.bottom.mas_offset(0);
               make.left.mas_offset(BiLiWidth(0)+(WySCREENWIDTH)/2*i);
           }];
           btn.tag = i;
           if (btn.tag == 0) {
               [btn setBackgroundColor:[UIColor whiteColor]];
               [btn setImage:[UIImage imageNamed:@"联系商家"] forState:0];
           }
           else
           {
               [btn setBackgroundColor:UIColorFromRGB(0xFADB14)];
               [btn setTitle:@"取消订单" forState:0];
               [btn setTitleColor:[UIColor whiteColor] forState:0];
           }
       }
    
    
    
    NSArray *fuleiArray = @[_BuyVcDetailsDicy[@"name"],_BuyVcDetailsDicy[@"UserName"],_BuyVcDetailsDicy[@"Score"],_BuyVcDetailsDicy[@"money"]];
    for (int i = 0; i<fuleiArray.count; i++) {
        UILabel *labe = [UILabel labelWithContent:fuleiArray[i]superView:self.ThreeView textColor:WyBlackColor font:WySYSTEMFONT(14) textAlignment:NSTextAlignmentLeft];
        [labe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(200), BiLiWidth(20)));
            make.left.equalTo(self.PicImg.right).offset(BiLiWidth(10));
            make.top.mas_offset(BiLiWidth(10)+BiLiWidth(25)*i);
        }];
        labe.tag = i;
        if (labe.tag == 0) {
            _NameLabe = labe;
        }else if (labe.tag == 1)
        {
            _UserNameLabe = labe;
            _UserNameLabe.textColor = UIColorFromRGB(0x999999);
            
        }
        else if (labe.tag == 2)
        {
            _ScoreLabe = labe;
            _ScoreLabe.textColor = UIColorFromRGB(0xFADB14);
    
        }
        else if (labe.tag == 3)
        {
            _MoneyLabe = labe;
            _MoneyLabe.textColor = UIColorFromRGB(0xFF4949);
            
        }
    }
    
    
    
    
}
-(void)selector:(UIButton *)button{
    
                    [MyProgressHUD showWithMaskType:MyProgressHUDMaskTypeBlack];

                         //定时器
                         dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                            
                           [MyProgressHUD dismiss];
                             
                             if (button.tag == 0) {
                                 [[AlertControllerCustom shareInstance] showAlert:@"请拨打商家服务热线\n0371-66666" viewController:self];
                             }
                             else
                             {
                                 [[AlertControllerCustom shareInstance] showAlert:@"请返回主页面取消！" viewController:self];
                                 dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 2.0 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
                                 [self.navigationController popViewControllerAnimated:YES];
                                     });
                             }
                             
                          
           
                });
    
}

- (UIScrollView *)WyScrollView {
    
    if (!_WyScrollView) {
        _WyScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
        [self.view addSubview:_WyScrollView];
        _WyScrollView.userInteractionEnabled = YES;
        _WyScrollView.showsVerticalScrollIndicator = NO;
        _WyScrollView.contentSize = CGSizeMake(WySCREENWIDTH, WySCREENHEIGHT*1);
        _WyScrollView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
        [_WyScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.top.mas_offset(0);
            
        }];
        [self BuyLabe];
        [self LineView];
        [self OneView];
        [self TwoView];
        [self ThreeView];
    }
    return _WyScrollView;
}
-(UIView *)OneView

{
    
    if (!_OneView) {
        _OneView = [[UIView alloc]init];
        [self.WyScrollView addSubview:_OneView];
        _OneView.backgroundColor = [UIColor whiteColor];
        [_OneView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(WySCREENWIDTH, BiLiWidth(119)));
            make.top.mas_offset(BiLiWidth(90));
            make.centerX.mas_offset(0);
        }];
       
    }
    return _OneView;
    
}

-(UIView *)TwoView

{
    
    if (!_TwoView) {
        _TwoView = [[UIView alloc]init];
        [self.WyScrollView addSubview:_TwoView];
        _TwoView.userInteractionEnabled = YES;
        _TwoView.backgroundColor = [UIColor whiteColor];
        [_TwoView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(WySCREENWIDTH, BiLiWidth(96)));
            make.top.equalTo(self.OneView.bottom).offset(BiLiWidth(20));
            make.centerX.mas_offset(0);
        }];
        
    }
    return _TwoView;
    
}
-(UIView *)ThreeView

{
    
    if (!_ThreeView) {
        _ThreeView = [[UIView alloc]init];
        [self.WyScrollView addSubview:_ThreeView];
        _ThreeView.userInteractionEnabled = YES;
        _ThreeView.backgroundColor = [UIColor whiteColor];
        [_ThreeView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(WySCREENWIDTH, BiLiWidth(120)));
            make.top.equalTo(self.TwoView.bottom).offset(BiLiWidth(20));
            make.centerX.mas_offset(0);
        }];
        
        [self PicImg];
    }
    return _ThreeView;
    
}


- (UILabel *)BuyLabe

{
    if (!_BuyLabe) {
        
        _BuyLabe = [UILabel labelWithContent:@"已购买" superView:self.WyScrollView textColor:WyBlackColor font:WySYSTEMFONT(18) textAlignment:NSTextAlignmentCenter];
        [_BuyLabe mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(200), BiLiWidth(25)));
            make.centerX.mas_offset(0);
            make.top.mas_offset(BiLiWidth(16));
        }];
        
    }
    return _BuyLabe;
}

- (UIView *)LineView

{
    
    if (!_LineView) {
        _LineView = [[UIView alloc]init];
        [self.WyScrollView addSubview:_LineView];
        _LineView.backgroundColor = UIColorFromRGB(0xCCCCCC);
        [_LineView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(160), BiLiWidth(2)));
            make.top.equalTo(self.BuyLabe.bottom).offset(BiLiWidth(20));
            make.centerX.mas_offset(0);
        }];
        
    }
    return _LineView;
    
}

- (UIImageView *)PicImg

{
    if (!_PicImg) {
        _PicImg = [UIImageView imageWithImgName:_BuyVcDetailsDicy[@"img"] superView:self.ThreeView];
        _PicImg.backgroundColor = WyColor;
        WyViewRadius(_PicImg, BiLiWidth(5));
        [_PicImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.size.equalTo(CGSizeMake(BiLiWidth(65), BiLiWidth(95)));
            make.top.mas_offset(BiLiWidth(10));
            make.left.mas_offset(BiLiWidth(20));
        }];
    }
    return _PicImg;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
